/**
 * 消息详情页Activity，用于展示消息内容并处理返回结果
 */
package com.example.gitpart03;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class MessageActivity extends AppCompatActivity {
    /**
     * 初始化Activity，设置布局并加载消息数据
     * @param savedInstanceState 保存的实例状态
     */
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_message);

        Intent intent = getIntent();
        ImageView messageImg = findViewById(R.id.img_imgId);
        TextView briefText = findViewById(R.id.text_brief);
        // 设置消息图片和内容
        messageImg.setImageResource(intent.getIntExtra("messageImg", R.drawable.main1));
        briefText.setText(intent.getStringExtra("messageBrief"));
    }

    /**
     * 处理选择按钮点击事件，返回结果并关闭当前Activity
     * @param view 点击的视图
     */
    public void select(View view) {
        Intent intent = new Intent();
        setResult(1002, intent);
        finish();
    }
}
